<template>
  <div>
    <!-- 利用element-ui 进行容器布局 -->
    <el-container>
      <el-header height="70px">
        XXX大型后台管理系统
        <div class="admin">
          <div>用户名：{{ $store.getters.getUser.username }}</div>
          <el-button @click="logout" type="danger" size="small"
            >退出登录</el-button
          >
        </div>
      </el-header>
      <el-container>
        <el-aside width="220px">
          <v-nav></v-nav>
        </el-aside>
        <el-main>
          <!-- 二级路由出口 -->
          <router-view></router-view>
        </el-main>
      </el-container>
    </el-container>
  </div>
</template>

<script>
//引入封装好的左侧菜单组件
import vNav from "../components/vNav.vue";
export default {
  data() {
    return {};
  },
  components: {
    vNav,
  },
  methods: {
    //封装一个退出登录事件
    logout() {
      //清空登录状态
      this.$store.dispatch("changeUserAction", false);
      this.$router.push("/login");
    },
  },
};
</script>

<style scoped>
.el-header {
  background: pink;
}
.admin {
  position: fixed;
  right: 20px;
  top: 10px;
}
</style>
